// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import Vuebar from 'vuebar'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import 'normalize.css/normalize.css'
import 'nprogress/nprogress.css'
import '@/assets/styles/index.less'
// import '@/assets/styles/element-ui.less'
import App from './App'
import '@/assets/iconfont-default'
import router from './router/'
import store from './store/'
import vueMoment from 'vue-moment'
import directive from './tools/directive'
import commonTitle from './pages/main/components/common_title.vue'
Vue.component('commonTitle', commonTitle)
Vue.use(Vuebar)
Vue.use(ElementUI, { size: 'small' })
Vue.use(vueMoment)
Vue.config.productionTip = false
Vue.filter('genderFilter', function (value) {
  switch (value) {
    case 1:
      return '男'
    case 2:
      return '女'
    case -1:
      return '未知'
  }
})
Vue.filter('examineFilter', function (value) {
  switch (value) {
    case 0:
      return '待审核'
    case 1:
      return '通过'
    case -1:
      return '驳回'
  }
})

Vue.filter('isTransform', function (value) {
  switch (value) {
    case true:
      return '是'
    case false:
      return '否'
    default:
      return ''
  }
})
Vue.filter('nullFilter', function (value) {
  switch (value) {
    case null:
      return '--'
    case '':
      return '--'
    case undefined:
      return '--'
    default:
      return value
  }
})
Vue.filter('politicsStatusFilter', function (value) {
  switch (value) {
    case -1:
      return '未知'
    case 1:
      return '群众'
    case 2:
      return '中共党员'
    case 3:
      return '中共预备党员'
    case 4:
      return '共青团员'
    case 5:
      return '民革党员'
    case 6:
      return '民盟盟员'
    case 7:
      return '民建会员'
    case 8:
      return '民进会员'
    case 9:
      return '农工党党员'
    case 10:
      return '致公党党员'
    case 11:
      return '九三学社社员'
    case 12:
      return '台盟盟员'
    case 13:
      return '无党派民主人士'
    default:
      return null
  }
})

Vue.filter('percent', function (value) {
  let str = Number(value * 100).toFixed(3)
  str += '%'
  return str
})

Vue.filter('modifyNum', function (value) {
  switch (value) {
    case null:
      return 0
    default:
      return value
  }
})

// 指令
Vue.directive('permission', directive)
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: {
    App
  },
  template: '<App/>'
})
